/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.runtime.component
{
	import mx.containers.HBox;
	import mx.controls.HRule;
	import mx.controls.Label;

	
	[DefaultProperty("_text")]
	/**
	 * 域组件.
	 * 该组件内部包含一个label和一个HRule.
	 * 用于在页面中分域展示数据. 
	 * 
	 */	
	public class BOPRegion extends HBox
	{
		private var _RegionLabel:Label;
		private var _line:HRule;
		private var _text:String;
		private var _hruleWidth:String;

		public function BOPRegion()
		{
			super();
			_line=new HRule();
			_line.height=20;
			_RegionLabel=new Label();
			_RegionLabel.text=this._text;
			this.addChild(_RegionLabel);
			this.addChild(_line);
		}

		override public function initialize():void
		{
			super.initialize();
			_RegionLabel.text=_text;
			
		}

		public function set text(value:String):void
		{
			this._text=value;

		}

		public function get text():String
		{
			return this._text;
		}

		public function set line(value:HRule):void
		{
			this._line=value;
		}

		public function get line():HRule
		{
			return this._line;
		}
		
		public function set hruleWidth(value:String):void
		{
			if(value.indexOf("%")>0){
				try{
					this._line.percentWidth = Number(value.substring(0,value.length-1));
					if(isNaN(this._line.percentWidth)){
						this._line.percentWidth = 90;
					}
				}catch(ec:Error){
					this._line.percentWidth = 90;
				}
			}else{
				try{
					this._line.width = Number(value);
				}catch(ec:Error){
					if(isNaN(this._line.width)){
						this._line.width = 200;
					}
				}
			}
		}

		public function get hruleWidth():String
		{
			return this._hruleWidth;
		}
		


	}
}